/*
	Copyright (C) 2008 Demiurg-HG
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
// i_netsys.h - 


#pragma once

const uint SV_MAXCLIENTS	=	256;


interface	INetTransmitter {
		virtual		~INetTransmitter ( void ) {};
		virtual int	Recv	( void *data, uint size ) = 0;
		virtual int	Send	( void *data, uint size ) = 0;
	};

interface INetServer : public INetTransmitter
	{
		virtual 		~INetServer			( void ) {};

		virtual void	Run					( word port ) = 0;
		virtual void	Kill				( void ) = 0;
		virtual	bool	IsRunning			( void ) = 0;

		virtual bool	IsClientConnected	( uint cl ) = 0;
		virtual void	AcceptClient		( void ) = 0;
		virtual void	DisconnectClient	( uint cl, int err_code ) = 0;
		virtual void	SwitchClient		( uint cl ) = 0;
		virtual int		Recv				( void *data, uint size ) = 0;
		virtual int		Send				( void *data, uint size ) = 0;
	};                  

interface	INetClient : public INetTransmitter
	{
		virtual			~INetClient		( void ) {};
		virtual void	Connect			( const char *addr, word port ) = 0;
		virtual void	Disconnect		( void ) = 0;
		virtual bool	IsConnected		( void ) = 0;
		
		virtual int		Send			( void *data, uint size ) = 0;
		virtual int		Recv			( void *data, uint size ) = 0;	
	};


interface INetworkSystem
	{
		virtual				~INetworkSystem	( void ) {}

		virtual	INetServer	*CreateServer		( void ) = 0;
		virtual void		DestroyServer		( INetServer *net_sv ) = 0;
		
		virtual INetClient	*CreateClient		( void ) = 0;
		virtual void		DestroyClient		( INetClient *net_cl ) = 0;
	};